// src/config/settingsConfig.ts
import { Component } from 'vue'
import { Setting, Bell, Lock} from '@element-plus/icons-vue'

export interface SettingField {
  name: string
  label: string
  type: 'input' | 'select' | 'switch' | 'number' | 'custom'
  options?: Array<{ label: string; value: string }>
  props?: Record<string, any>
  modelKey: string // 在 formData 中对应的 key
}

export interface SettingTab {
  id: string
  title: string
  icon: Component
  fields?: SettingField[] // 表单字段配置（用于基本/通知/安全设置）
  dataKey?: string // 对应的数据模型 key
  renderType?: 'form' | 'table' | 'custom' // 渲染类型
  tableConfig?: {
    columns: Array<{
      prop: string
      label: string
      width?: string
    }>
    data: any[]
    onAdd?: () => void
    onEdit?: (row: any) => void
    onRemove?: (row: any) => void
  }
  customComponent?: Component // 自定义组件（高级场景）
}

export const settingsConfig: SettingTab[] = [
  {
    id: 'basic',
    title: '基本设置',
    icon: Setting,
    renderType: 'form',
    dataKey: 'basicSettings',
    fields: [
      {
        name: 'systemName',
        label: '系统名称',
        type: 'input',
        modelKey: 'systemName'
      },
      {
        name: 'timezone',
        label: '时区',
        type: 'select',
        options: [
          { label: '北京时间 (UTC+8)', value: 'UTC+8' },
          { label: '东京时间 (UTC+9)', value: 'UTC+9' },
          { label: '纽约时间 (UTC-5)', value: 'UTC-5' }
        ],
        modelKey: 'timezone'
      },
      {
        name: 'language',
        label: '语言',
        type: 'select',
        options: [
          { label: '中文', value: 'zh-CN' },
          { label: 'English', value: 'en-US' }
        ],
        modelKey: 'language'
      },
      {
        name: 'theme',
        label: '主题',
        type: 'custom', // 自定义渲染 radio
        modelKey: 'theme'
      }
    ]
  },
  {
    id: 'notification',
    title: '通知设置',
    icon: Bell,
    renderType: 'form',
    dataKey: 'notificationSettings',
    fields: [
      { name: 'email', label: '邮件通知', type: 'switch', modelKey: 'email' },
      { name: 'sms', label: '短信通知', type: 'switch', modelKey: 'sms' },
      { name: 'push', label: 'APP推送', type: 'switch', modelKey: 'push' },
      { name: 'alerts', label: '警报通知', type: 'switch', modelKey: 'alerts' },
      { name: 'dailyReport', label: '日报提醒', type: 'switch', modelKey: 'dailyReport' },
      { name: 'weeklyReport', label: '周报提醒', type: 'switch', modelKey: 'weeklyReport' }
    ]
  },
  {
    id: 'security',
    title: '安全设置',
    icon: Lock,
    renderType: 'form',
    dataKey: 'securitySettings',
    fields: [
      {
        name: 'passwordStrength',
        label: '密码强度',
        type: 'select',
        options: [
          { label: '低 (6位以上)', value: 'low' },
          { label: '中 (8位以上，包含数字和字母)', value: 'medium' },
          { label: '高 (10位以上，包含数字、字母和特殊字符)', value: 'high' }
        ],
        modelKey: 'passwordStrength'
      },
      {
        name: 'loginLock',
        label: '登录失败锁定',
        type: 'switch',
        modelKey: 'loginLock'
      }
    ]
}]